<template>
  <div class="login_wrap">
    <div class="logo">
      <img
        src="../../assets/logo.jpg"
        alt=""
      >
    </div>
    <div class="form_wrap">
      <el-form
        ref="formRef"
        :model="loginData"
        label-width="100px"
        class="demo-dynamic"
      >
      <h2 class="loginTitle">欢迎登录</h2>
        <el-form-item prop="username">

          <el-input
            placeholder="请输入账号"
            :prefix-icon="User"
            v-model="loginData.username"
          />
        </el-form-item>
        <el-form-item prop="password">
          <el-input
            placeholder="请输入密码"
            type="password"
            v-model="loginData.password"
            :prefix-icon="Lock"
          />
          
        </el-form-item>
        <el-checkbox
            style="position:relative;left:-133px; top:-15px"
            v-model="checked1"
            label="记住密码"
            size="large"
          />
        <el-button
          style="width:350px;position:relative;top:-10px"
          color="#3A62D7"
          type="primary"
          class="login_btn"
          @click="handleLogin"
        >登录</el-button>
        <div class="signUp"><span>没有账号?<a href="#">去注册</a></span> <a href="#">忘记密码</a></div>
      </el-form>
      <!-- <p>{{num}}</p> -->
    </div>
  </div>
</template>    
<script>
import { reactive, toRefs } from "vue";
import { useStore } from "vuex";
import { useRouter } from "vue-router";
import { User, Lock } from '@element-plus/icons-vue'
export default {
  name: "login",
  setup () {
    const store = useStore();
    const router = useRouter();
    const data = reactive({
      loginData: {
        username: "",
        password: "",
      },
    });

    const handleLogin = () => {
      store.commit("setUserInfo", data.loginData);
      //跳转/user
      localStorage.setItem("loginData", JSON.stringify(data.loginData));

      router.push({
        path: "/user",
      });
      setTimeout(() => {
        console.log("1");
      }, 3000);
    };

    return {
      ...toRefs(data),
      handleLogin,
      User,
      Lock
    };
  },
};
</script>
<style  scoped>
.login_wrap {
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgb(214, 233, 255);
}
.form_wrap {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 700px;
  width: 500px;
  background: #ffffff;
}
.logo {
  width: 750px;
  height: 700px;
}
.logo img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.loginTitle {
  position: relative;
  bottom: 100px;
  width: 30%;
  border-bottom: 4px solid rgb(143, 166, 232);
  padding-bottom: 5px;
}
.el-form {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  position: relative;
  bottom: -10px;
  width: 100%;
}

.rembPassowrd {
  position: relative;
  left: -21px;
  top: -10px;
}
.el-input {
  width: 350px;
  border-bottom: 1px solid rgb(230, 230, 230);
  position: relative;
  left: -50px;
  --color: blue;
  --el-border-color: none;
  --el-border-color-hover: none;
  --el-border-color: none;
  --el-input-focus-border-color: rgb(130, 207, 248);
  --el-color-danger: none;
}
.signUp {
  position:relative;
  top:6px;
  width: 70%;
  display: flex;
  justify-content: space-between;
  font-size: 12px;
}
a{
  text-decoration: none;
  color: blue;
}
</style>